﻿@model Abc.Application.HtAdminServices.HtMenuOut;
<form class="layui-form" action="">
    <input type="hidden" asp-for="Id" />
    <div class="layui-card-body">
        <ul id="selectPermission" class="dtree" data-id=""></ul>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <div class="layui-btn submitbtn" lay-submit lay-filter="submit">提交数据</div>
            <div class="layui-btn layui-btn-danger closewindow">关闭窗口</div>
            <div class="layui-btn layui-btn-danger refreshwindow">重新加载</div>
        </div>
    </div>
</form>

@section Scripts{
    <script>
        layui.define(['element', 'jquery', 'form', 'table', 'laydate', 'dtree', 'iconPicker'], function () {
            var $ = layui.jquery;
            var upload = layui.upload;
            var form = layui.form;
            var table = layui.table;
            var laydate = layui.laydate;
            var element = layui.element;
            var dtree = layui.dtree;
            var iconPicker = layui.iconPicker;

            //Info 初始化
            abc.infoInit();
             //提交
             form.on('submit(submit)', function (obj) {
                 //obj.field.IsEnable=$('#IsEnable').is(':checked');
                 //obj.field.Remark = Remark.getContent();
                 @*var a = dtree.getNowParam("selectPermission");
                 obj.field.PMId = dtree.getNowParam("selectPermission").nodeId;  //获取当前选中节点值*@

                 var params = dtree.getCheckbarNodesParam("selectPermission");
                 var ids = "";
                 $(params).each(function (index, element) {
                     if (element.nodeId.indexOf("p_") == -1) {
                         ids += element.nodeId + ",";
                     }
                 });
                 ids = ids.substr(0, ids.length - 1);
                 obj.field.permissionstrs = ids;
                 abc.post({
                     url: "@(Url.Action("SetMenuPermission"))"
                     , data: obj.field
                 });

                 layer.msg(ids);

                 return false;
             });

            dtree.render({
                elem: "#selectPermission",
                //initLevel: "1",
                method: 'get',
                url: "@Url.Action("GetPermissionDtree")?menuid=@(Model?.Id)",
                initLevel: 1,
                checkbar: true,
                checkbarType: "all", // 默认就是all，其他的值为： no-all  p-casc   self  only
                menubar: true,
                menubarFun: {
                    group: ["moveDown", "moveUp", "refresh", {
                        menubarId: "extGroupId1",  // 按钮的唯一ID
                        icon: "dtree-icon-homefill", // 从dtreefont库中选取
                        title: "自定义按钮1",  // 按钮的提示标题
                        handler: function (node, $div) {  //扩展按钮的回调函数
                            layer.msg(JSON.stringify(node));
                        }
                    }]
                }
            });
             //form.verify({
             //    Name: function (value) {
             //        if (value <= 0) {
             //            return 'Name不能为空';
             //        }
             //    },
             //    Money: [
             //        /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/
             //        ,'支付金额错误，最多2位小数，不能以小数点结尾'
             //    ],
             //});

         });
    </script>
}
